﻿using System;
using System.Collections.Generic;
using RiskMan.Config;
using RiskMan.DataClass.Models.Plaza_II;
using System.Collections.ObjectModel;
using RiskMan.DataClass.Models.Plaza_II.FortsFootCommonRepl;
using RiskMan.DataClass.Models.Plaza_II.FortsFutInfoRepl;
using RiskMan.DataClass.Models.Plaza_II.FortsFutorderBookRepl;
using RiskMan.DataClass.Models.Plaza_II.FortsFuttradeRepl;
using RiskMan.DataClass.Models.Plaza_II.FortsInfoRepl;
using RiskMan.DataClass.Models.Plaza_II.FortsPartRepl;
using RiskMan.DataClass.Models.Plaza_II.FortsPosRepl;
using RiskMan.DataClass.Models.Plaza_II.FortsVmRepl;

namespace RiskMan.DataClass
{
    public partial class Data
    {


        #region RobotPlazaII
        
        public ObservableCollection<RobotItemPlazaII>  RobotItemPlazaIIlist = new ObservableCollection<RobotItemPlazaII>();
        public ObservableCollection<TestCalculationIndikators> TestCalculationIndikatorses = new ObservableCollection<TestCalculationIndikators>();

        #endregion

        #region Потоки

        #region FortsFootCommonRepl

        public ObservableCollection<Common> CommonList = new ObservableCollection<Common>();

        #endregion

        #region FortsFutInfoRepl

        public ObservableCollection<DeliveryReport> DeliveryReportList = new ObservableCollection<DeliveryReport>();
        public ObservableCollection<FutInstruments> FutInstrumentsList = new ObservableCollection<FutInstruments>();
        public ObservableCollection<FutRejectedOrders> FutRejectedOrdersList = new ObservableCollection<FutRejectedOrders>();
        public ObservableCollection<FutSessContents> FutSessContentsList = new ObservableCollection<FutSessContents>();
        public ObservableCollection<FuturesParams> FuturesParamsList = new ObservableCollection<FuturesParams>();
        public ObservableCollection<FutVcb> FutVcbList = new ObservableCollection<FutVcb>();
        public ObservableCollection<MultilegDict> MultilegDictList = new ObservableCollection<MultilegDict>();
        public ObservableCollection<Session> SeesionList = new ObservableCollection<Session>();



        #endregion

        #region FortsFutorderBookRepl

        public ObservableCollection<Info> InfoList = new ObservableCollection<Info>();
        public ObservableCollection<Orders> OrdersList = new ObservableCollection<Orders>();

        #endregion

        #region FortsFuttradeRepl

        public ObservableCollection<Models.Plaza_II.FortsFuttradeRepl.Deal> DealList = new ObservableCollection<Models.Plaza_II.FortsFuttradeRepl.Deal>();
        public ObservableCollection<Heratbeat> HeratbeatList = new ObservableCollection<Heratbeat>();
        public ObservableCollection<MultilegOrdersLog> MultilegOrdersLogList = new ObservableCollection<MultilegOrdersLog>();
        public ObservableCollection<MultlegDeal> MultlegDealList = new ObservableCollection<MultlegDeal>();
        public ObservableCollection<OrdersLog> OrdersLogList = new ObservableCollection<OrdersLog>();
        public ObservableCollection<SysEvents> SysEventsList = new ObservableCollection<SysEvents>();

        #endregion

        #region FortsInfoRepl

        public ObservableCollection<BaseContractsParams> BaseContractsParamsList = new ObservableCollection<BaseContractsParams>();

        #endregion

        #region FortsOrdlogRepl

        public ObservableCollection<Models.Plaza_II.FortsOrdlogRepl.MultilegOrdersLog> FortsOrdlogReplMultilegOrdersLogList = new ObservableCollection<Models.Plaza_II.FortsOrdlogRepl.MultilegOrdersLog>();
        public ObservableCollection<Models.Plaza_II.FortsOrdlogRepl.OrdersLog> FortsOrdlogReplOrdersLogList = new ObservableCollection<Models.Plaza_II.FortsOrdlogRepl.OrdersLog>();
        public ObservableCollection<Models.Plaza_II.FortsOrdlogRepl.SysEvents> FortsOrdlogReplSysEventsList = new ObservableCollection<Models.Plaza_II.FortsOrdlogRepl.SysEvents>();

        #endregion

        #region FortsPartRepl

        public ObservableCollection<Part> PartList = new ObservableCollection<Part>();

        #endregion

        #region FortsPosRepl

        public ObservableCollection<Position> PositionList = new ObservableCollection<Position>();

        #endregion

        #region FortsVmRepl

        public ObservableCollection<FutVm> FutVmList = new ObservableCollection<FutVm>();

        #endregion

        #endregion

        public Data()
        {

        }

        public IEnumerable<string> GetSeccodeList()
        {
            List<string> result = new List<string>();

            foreach (var item in FutInstrumentsList)
            {
                result.Add(item.ShortIsin);
            }
            

            return result;
        }

        public double GetEnterPrice(string seccode, string clientcode, string account, double currpos)
        {
            double result = 0;

            //if (currpos > 0)
            //    for (int i = DealList.Count - 1; i >= 0; i--)
            //        if (DealList[i].Account == account &&
            //            DealList[i].ClientCode == clientcode &&
            //            DealList[i].Seccode == seccode &&
            //            DealList[i].Operation == Cfg.Buy)
            //            return DealList[i].Price;

            //if (currpos < 0)
            //    for (int i = DealList.Count - 1; i >= 0; i--)
            //        if (DealList[i].Account == account &&
            //            DealList[i].ClientCode == clientcode &&
            //            DealList[i].Seccode == seccode &&
            //            DealList[i].Operation == Cfg.Sell)
            //            return DealList[i].Price;

            return result;
        }

        public double GetSlActive(string seccode, string clientcode, string account, double currpos)
        {
            double result = 0;

            //if (currpos > 0)
            //    for (int i = StopOrderList.Count - 1; i >= 0; i--)
            //        if (StopOrderList[i].TradeAccount == account &&
            //            StopOrderList[i].ClientCode == clientcode &&
            //            StopOrderList[i].Seccode == seccode &&
            //            StopOrderList[i].Operation == Cfg.Sell)
            //            return StopOrderList[i].StopPrice;

            //if (currpos < 0)
            //    for (int i = StopOrderList.Count - 1; i >= 0; i--)
            //        if (StopOrderList[i].TradeAccount == account &&
            //            StopOrderList[i].ClientCode == clientcode &&
            //            StopOrderList[i].Seccode == seccode &&
            //            StopOrderList[i].Operation == Cfg.Buy)
            //            return StopOrderList[i].StopPrice;

            return result;
        }



        public List<string> ListPath = new List<string>();

       

    }
}